import defaultSettings from '@/settings'

export const useSettingsStore = defineStore('settings', () => {
  const showSettingsState = ref(defaultSettings.showSettings)
  const fixedHeaderState = ref(defaultSettings.fixedHeader)
  const sidebarLogoState = ref(defaultSettings.sidebarLogo)

  const changeSetting = ({ key, value }) => {
    if (['showSettings', 'fixedHeader', 'sidebarLogo'].includes(key)) {
      switch (key) {
        case 'showSettings':
          showSettingsState.value = value
          break
        case 'fixedHeader':
          fixedHeaderState.value = value
          break
        case 'sidebarLogo':
          sidebarLogoState.value = value
          break
      }
    }
  }

  return {
    showSettings: showSettingsState,
    fixedHeader: fixedHeaderState,
    sidebarLogo: sidebarLogoState,
    changeSetting
  }
})
